﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using ECONTACT.Controller;

namespace ECONTACT
{
    public partial class frmMonHoc : Form
    {
        MonHocCtrl m_MonHocCtrl = new MonHocCtrl();
        public frmMonHoc()
        {
            InitializeComponent();
        }

        private void frmMonHoc_Load(object sender, EventArgs e)
        {
            m_MonHocCtrl.HienThi(dGVMonHoc, txtMaMH, txtTenMonHoc, txtHeSo);
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            m_MonHocCtrl.LuuMonHoc(txtTenMonHoc.Text, txtHeSo.Text);
            m_MonHocCtrl.HienThi(dGVMonHoc, txtMaMH, txtTenMonHoc, txtHeSo);
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            m_MonHocCtrl.UpdateMonHoc(txtMaMH.Text, txtTenMonHoc.Text, txtHeSo.Text);
            m_MonHocCtrl.HienThi(dGVMonHoc, txtMaMH, txtTenMonHoc, txtHeSo);
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (dGVMonHoc.RowCount == 0)
            {
                MessageBox.Show("Bạn chưa chọn dòng nào làm sao xóa!", "Thông báo");
            }
            else if (MessageBoxEx.Show("Bạn có chắc là xóa thiệt hok ?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                m_MonHocCtrl.DeleteMonHoc(txtMaMH.Text);
                m_MonHocCtrl.HienThi(dGVMonHoc, txtMaMH, txtTenMonHoc, txtHeSo);
            }
        }
    }
}
